import {defineStore} from "pinia";
import {setLocalStorage} from "@/utils";

interface taskType {
    mid: string,
    missionCode: string,
    missionName: string,
    missionType?: string
    gloableId?: string,
    parentMissionID?: string,
    missionTheoryT0Date?: string,
    missionTheoryT0Time?: string,
    t0type?: string
}

export const usePageSelectStore = defineStore({
    id: 'pageSelect',
    state: () => {
        return {
            page: {},
            currentPageId: '',
            currentPageName: '',
            info: {},
            isSave: false
        }
    },
    getters: {
        // getMid(): String {
        //     return this.task.mid
        // },
        // getMissionName(): String {
        //     return this.task.missionName
        // },
        getCurrentId(): string {
            return this.currentPageId
        },
        getInfo(): any {
            return this.info
        },
        getSaveState(): boolean {
            return this.isSave
        }
    },
    actions: {
        // setItem<T extends keyof taskType, K extends taskType[T]>(
        //     key: T,
        //     value: K
        // ): void {
        //     this.$patch(state => {
        //         state[key] = value
        //     })
        // },
        setValue(value: any) {
            this.page = Object.assign(this.page, value)
        },
        setCurrent(str: string) {
            this.currentPageId = str
        },
        setInfo(obj: any) {
            this.info = obj
        },
        setSaveState(val: boolean) {
            this.isSave = val
        }
    }
})

